<?php
namespace app\common\model;

use think\Model;

class TermMuch extends Model
{
    //相对关联 belongsTo('关联模型名','外键名','关联表主键名',['模型别名定义'],'join类型');
	public function term()
    {
		return $this->belongsTo('Term','term_id')->field('term_id,term_name,term_slug,term_module,term_status,term_order')->bind('term_name,term_slug,term_module,term_status,term_order');
	}
    
    //一对多
    public function termMeta()
    {
        return $this->hasMany('TermMeta','term_id')->field('term_id,term_meta_id,term_meta_key,term_meta_value');
	}
    
    //一对多
    public function termMap()
    {
		return $this->hasMany('TermMap','term_much_id')->field('detail_id,term_much_id');
	}
    
    //多对多 belongsToMany('关联模型名','中间表名','外键名','当前模型关联键名',['模型别名定义'])
    public function info()
    {
		return $this->belongsToMany('Info','TermMap','detail_id','term_much_id');
	}
}